<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
</head>
<body class="no-skin">
<!-- 以下为内容 -->
	<div class="main-content1">
		<div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
            </script>
            <ul class="breadcrumb"  style="margin-top:10px">
            <li>
                <i class="ace-icon fa fa-home home-icon"></i>
                <a href="#">后台管理    </a>                        </li>
            <li class="active">菜单管理</li>
        </ul>
        <!-- 路径结束 -->
        </div>
        
        <div class="page-content">
            <div class="row">
                <div class="tab-content no-border padding-24">
                    <div class="col-sm-3">
                         <div class="widget-box ">
                              <div class="widget-header">
                                  <h4 class="widget-title lighter smaller">系统菜单</h4>
                              </div>
                              <div class="widget-body" style="height:400px; overflow-y:auto">
                                   <div class="widget-main padding-8">
                                        <ul id="treeDemo" class="ztree"></ul>
                                    </div>
                              </div>
                           </div>
                     </div>
                     
                     
                     <div class="col-sm-9">
                         <iframe src="" id="rightList" name="rightList" frameborder="0" style="width:100%; height:800px" ></iframe>                  
                     </div>
                  </div>
              </div>
          </div>
  </div><!-- /.main-container -->
<script type="text/javascript">
	//节点点击事件
	function zTreeOnClick(event,treeId,treeNode){
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
		treeObj.expandNode(treeNode,true,false,true,false);
	    $("#rightList").attr("src","../../auth/menu/forwardMenuChildrenList.htm?parentCode="+treeNode.menuCode);
	}
	
	
	var setting={
	            data:{
    	            simpleData:{
    	            enable: true,
    	            idKey:"menuCode",
    	            pIdKey:"parentCode",
    	            rootPId:null
    	            },
                    key:{
                        name:"menuName",
                        url:""
                    }
	            },
	            callback: {
	                onClick: zTreeOnClick
	            }
	}; 
	
	//得到树
	$(document).ready(function(){
		initTree(1,null);
	});
	
	function initTree(typeVal,node){
	    $.ajax({
	        type:"POST",
	        contentType: 'application/json',
	        dataType:"json",
	        url:contextPath+"/auth/menu/getListMenu.json",
	        success:function(data){
    	        $.fn.zTree.init($("#treeDemo"), setting, data);
    	        //默认选中第一个根节点
    	        if(1==typeVal){
    	        	getSelectFirst();
    	        }else{
    	        	var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    	        	treeObj.expandNode(node,true);
        			treeObj.selectNode(node,false);
    	        }
	        },
	        error:function(){
	            $.Alert("系统错误！");
	        }
	    });
	  }  
	
	function getSelectFirst(){
	    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
        var node = treeObj.getNodeByParam("parentCode", null);
        treeObj.expandNode(node,true);
        treeObj.selectNode(node,false);
        zTreeOnClick(event,"treeDemo",node);
	}
	
	function refreshTree(typeVal){
	    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
        var nodes = treeObj.getSelectedNodes();
        initTree(typeVal,nodes[0]);
	}
	
		</script>
		

	</body>
</html>
